package com.sumainfor.pc.market.controller.rentadviser;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.market.service.RdSubletApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 转租申请
 */
@RestController
@RequestMapping("/rentadviser/RdSubletApply")
public class RdSubletApplyController {

    @Autowired
    private RdSubletApplyService rdSubletApplyService;

    /**
     *查询转租的申请列表
     */
    @GetMapping("/getSubletApplyList")
     public JsonResult getSubletApplyList(@RequestParam Map<String,Object>params, Pager pager){
        JsonResult result=new JsonResult();
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
        Integer cout=rdSubletApplyService.getSubletApplyListCount(params);
        if(cout==0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,cout);
        }
        List<Map<String,Object>> getCommunityList=rdSubletApplyService.getSubletApplyList(params);
        result=pageUtils.getJsonResult(getCommunityList, params, cout);
        return result;
    }
    /**
     *转租申请房源上架
     */
    @PostMapping("/updateSubletApply")
    public JsonResult updateSubletApply(@RequestBody Map<String,Object>params){
        System.out.println("接受到的参数:"+params);
        return rdSubletApplyService.updateSubletApply(params);
    }

}
